<extend name="Layout/ins_page" />

<block name="head"></block>
<block name="js"></block>

<block name="content">
    <link href="/sap/demo.css" rel="stylesheet" type="text/css" />
    <script src="/sap/scripts/boot.js" type="text/javascript"></script>
    <!--content begin-->

        <link rel="stylesheet" type="text/css" href="/Public/CSS/Report/StickStockDetail/tcal.css" />
        <script type="text/javascript" src="/Public/Scripts/Report/StickStockDetail/tcal.js"></script>
        <script src="/Public/Scripts/Report/StickStockDetail/bbpmm.js"></script>
        <style type="text/css">table tr td,th{border:1px solid ;}
        #t1{ margin: auto; font-size:15px;width:900px; text-align: center;}
        #c{  margin: auto; width:900px;}
        </style>
        <script src="/Public/Scripts/Report/StickStockDetail/1.js"></script>
        <script type="text/javascript" src="/Public/Scripts/Report/StickStockDetail/2.js"></script>
        <script type="text/javascript" src="/Public/Scripts/Report/StickStockDetail/3.js"></script>
        <script type="text/javascript" src="/Public/Scripts/Report/StickStockDetail/4.js"></script>
        <script type="text/javascript" src="/Public/Scripts/Report/StickStockDetail/5.js"></script>


    <div id="c">
        <form method='post' id="zhixiaokucunmingxiForm" name="zhixiaokucunmingxiForm" enctype="multipart/form-data">
        <input type="text" name="checkdate" id="checkdate" class="tcal" value='<?php echo $checkdate ?>'/>
        <a class="mini-button" onclick="search()">查询</a>
        <a class="mini-button" iconCls="icon-download" onclick="exportToexcel()">导出清单</a>
        </form>
    </div>

    <div id="chenkbox">
        <table id="t1"  border='1'cellspacing="0" cellpadding="0">
            <thead>
            <tr>
                <th onclick="sortTable('t1',0)" title="点击排序">
                    <select name="select" onchange="filterF()">
                        <foreach name="pmList" item="pl">
                            <option value="<?php echo $pl['Pmanager'];?>"><?php echo $pl['Pmanager'];?></option>
                        </foreach>
                </th>
                <th onclick="sortTable('t1',1)" title="点击排序">
                    物料号
                </th>
                <th onclick="sortTable('t1',2)" title="点击排序">
                    物料名
                </th>
                <th onclick="sortTable('t1',3)" title="点击排序">
                    数量
                </th>
                <th onclick="sortTable('t1',4)" title="点击排序">
                    库存价值
                </th>
                <th onclick="sortTable('t1',5)" title="点击排序">
                    最后销售日期
                </th>
                <th onclick="sortTable('t1',6)" title="点击排序" style="width:40px;">
                    是否3C
                </th>
                <th onclick="sortTable('t1',7)" title="点击排序">
                    品牌
                </th>
                <th onclick="sortTable('t1',8)" title="点击排序" style="width:40px;">
                    滞销日
                </th>
                <th onclick="sortTable('t1',9)" title="点击排序" style="width:40px;">
                    客户经理
                </th>
            </thead>

            <tbody>

            <foreach name="resultData" item="result">

                <tr align="center">

                    <td><a href="javascript:popPMLast12monthes('<?php echo $result['U_PManager']; ?>')"><?php echo $result['U_PManager']; ?></a></td>
                    <td><?php echo $result['ItemCode']; ?></td>
                    <td style="word-break:break-all; word-wrap:break-word;"><?php echo $result['ItemName']; ?></td>
                    <td><?php echo number_format(round($result['stockqty'],2));?></td>
                    <td><?php echo number_format(round($result['stockvalue'],2));?></td>
                    <td><?php echo date('Y/m/d', strtotime($result['lastmovedate']));?></td>
                    <td><?php echo $result['U_Is3C']; ?></td>
                    <td><?php echo $result['U_Brand']; ?></td>
                    <td><?php echo $result['stickdate']; ?></td>
                    <td><?php echo $result['cmanager']; ?></td>
                </tr>

            </foreach>

            </tbody>
        </table>

    </div>

    <script>

        function search(){
            var form =document.getElementById("zhixiaokucunmingxiForm");
            form.submit();
        }

    </script>

    <script>
        function popPMLast12monthes(pm) {
            mini.open({
                url:  "Report/zhixiaokucunPMLast12Monthes20171018/&pm="+pm,
                title: "",
                width: 800,
                height: 380,
                ondestroy: function (action) {
                    if (action == "ok") {

                    }

                }
            });

        }
    </script>

    <script>

        function exportToexcel(){

            var checkdate=document.getElementById('checkdate').value;

            var f=document.createElement("form");
            f.action="/Report/zhixiaokucunmingxi20171018excel";
            f.method="post";
            f.innerHTML="<input type='hidden' name='checkdate' value='"+checkdate+"'/>";
            document.body.appendChild(f);
            f.submit()

        }

    </script>
    <script>
        function filterF(){
            var sele=document.getElementsByName('select')[0];
            var oldL=sele.options[sele.selectedIndex].text;
            var l="<a href=\"javascript:popPMLast12monthes(\'"+oldL+"\')\">"+oldL+"</a>";
            var l2=sele.options[sele.selectedIndex].value;
            var t1=document.getElementById('t1');
            for(var i=1;i<t1.rows.length;i++){
                if(l=='全部'){t1.rows[i].style.display='';}else{
                    if(t1.rows[i].cells[0].innerHTML==l){
                        t1.rows[i].style.display='';
                    }else{
                        t1.rows[i].style.display='none';
                    }
                }
            }

        }
    </script>

    <!--content end-->
</block>